package com.example.demo.domain.product.entity;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Product {

	private String id;

	private String name;

	private String description;

	private BigDecimal price;

	private Instant createTime;

	public static Product create(String name, String description, BigDecimal price) {
		return new Product(name, description, price);
	}

	public Product(String name, String description, BigDecimal price) {
		super();
		this.id = UUID.randomUUID().toString();
		this.name = name;
		this.description = description;
		this.price = price;
		this.createTime = Instant.now();
	}

	public Collection<Product> getItems() {
		return Collections.unmodifiableCollection(Arrays.asList(this));
	}

}
